package com.etc.dao;

import com.etc.entity.Movie;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Administrator on 2019/5/24.
 */

@Repository
public interface UserRecordDao extends JpaRepository<Movie, Integer> {
    /**
     * 查询用户的订单   不包括座位
     *
     * @param userid
     * @return
     */
    @Query(nativeQuery = true, value = "SELECT  r.rid rid,m.mpicture mpicture,m.mname mname,r.buytime buytime,c.mstartime mstartime,r.payprice payprice,c.cname cname FROM Record r, User u ,Movie m,Cinema c where r.cid=c.cid and r.userid=u.userid and c.mid=m.mid and  u.userid=:userid ORDER BY r.buytime DESC")
    public List<Object[]> FindAllRecordByUserWithBefore(@Param("userid") Integer userid);

    @Query(nativeQuery = true,value = "SELECT seatid FROM recorddetails where rid=:rid")
    public List<String> FindSeatsByRid(@Param("rid") Integer rid);
}

